package UseIO.Practice;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;

public class FileDecodeAndEncode {
    public static void main(String[] args) throws IOException {
        encrypt();
        //decrypt();
    }
    public static void encrypt() throws IOException{
        FileInputStream fis = new FileInputStream("8.内置模块/UseIO/Practice/img.png");
        FileOutputStream fus = new FileOutputStream("8.内置模块/UseIO/Practice/encrypt.png");
        int b;
        while ((b=fis.read())!=-1){
            fus.write(b ^ 2);
        }
        fis.close();
        fus.close();
    }

    public static void decrypt() throws IOException{
        FileInputStream fis = new FileInputStream("8.内置模块/UseIO/Practice/encrypt.png");
        FileOutputStream fus = new FileOutputStream("8.内置模块/UseIO/Practice/img.png");
        int b;
        byte[] arr = new byte[1024];
        while ((b=fis.read(arr))!=-1){
            fus.write(b ^ 2);
        }
        fis.close();
        fus.close();
    }
}
